/********************************************************************************
* File Name:	mainwindow.cpp
* Description:	第3章 实例8：Table Widget的实例
* Reference book:《Linux环境下Qt4图形界面与MySQL编程》，机械工业出版社.2012.1
* E_mail: openlinux2011@gmail.com
*
********************************************************************************/
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QLabel>
#include <QDateTimeEdit>
#include <QComboBox>
#include <QSpinBox>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QLabel *label = new QLabel();
    label->setText("Tom");
    ui->tableWidget->setCellWidget(1,0,label);

    QComboBox *ComboBoxSex = new QComboBox();
    ComboBoxSex->addItem("Man");
    ComboBoxSex->addItem("Woman");

    ui->tableWidget->setCellWidget(1,1,ComboBoxSex);

    //QDateTimeEdit *dateTimeEdit1 = new QDataTimeEdit();

    QDateTimeEdit *dateTimeEdit1 = new QDateTimeEdit();
    dateTimeEdit1->setDateTime(QDateTime::currentDateTime());
    dateTimeEdit1->setDisplayFormat("dd/MM/yyyy");
    dateTimeEdit1->setCalendarPopup(true);
    ui->tableWidget->setCellWidget(1,2,dateTimeEdit1);

    QComboBox *ComboBoxWork1 = new QComboBox();
    ComboBoxWork1->addItem(tr("Worker"));
    ComboBoxWork1->addItem(tr("Farmer"));
    ComboBoxWork1->addItem(tr("Doctor"));
    ComboBoxWork1->addItem(tr("Lawyer"));
    ComboBoxWork1->addItem(tr("Solder"));
    ui->tableWidget->setCellWidget(1,3,ComboBoxWork1);

}

MainWindow::~MainWindow()
{
    delete ui;
}
